import { requestHttp } from "@/utils/request";
import { ReqPage, ResPage, ResultData } from "../types";

export interface OpenClientInfo {
  id?: number;
  appName: string;
  appId: string;
  appSecret: string;
  status?: number;
  createTime?: string;
  openUserId?: number;
}

/**
 * Get open client list with pagination
 */
export function getOpenClientList(params: ReqPage & Partial<OpenClientInfo>): Promise<ResultData<ResPage<OpenClientInfo>>> {
  return requestHttp.get("/open-client/info/page", { params });
}

/**
 * Get open client detail
 */
export function getOpenClientDetail(id: number) {
  return requestHttp.get<OpenClientInfo>(`/open-client/info/${id}`);
}

/**
 * Add new open client
 */
export function addOpenClient(data: OpenClientInfo) {
  return requestHttp.post<boolean>("/open-client/info/add", data);
}

/**
 * Update open client
 */
export function updateOpenClient(data: OpenClientInfo) {
  return requestHttp.post<boolean>("/open-client/info/update", data);
}

/**
 * Delete open client
 */
export function deleteOpenClient(ids: number[]) {
  return requestHttp.post<boolean>(`/open-client/info/delete/${ids.join(",")}`);
}
